package com.e3.bill.client;

import java.util.List;

import com.e3.web.widget.client.MyFormPanel;
import com.extjs.gxt.ui.client.widget.LayoutContainer;
import com.extjs.gxt.ui.client.widget.form.Field;
import com.extjs.gxt.ui.client.widget.form.FormPanel.LabelAlign;
import com.extjs.gxt.ui.client.widget.layout.FitLayout;
import com.google.gwt.user.client.Element;

public abstract class BillFormPanel<D> extends LayoutContainer {
	
	private MyFormPanel formPanel;

	@Override
	protected void onRender(Element parent, int index) {
		super.onRender(parent, index);
		setLayout(new FitLayout());
		add(getFormPanel());
	}
	
	protected MyFormPanel getFormPanel(){
		if(formPanel == null){
			formPanel = new MyFormPanel();
			formPanel.setHeaderVisible(false);
			formPanel.setColumnCount(getFormColumnCount());
			formPanel.setLabelAlign(LabelAlign.RIGHT);
			formPanel.setFormFields(getFormFields());
		}
		return formPanel;
	}
	
	protected abstract List<Field<?>> getFormFields();
	
	protected int getFormColumnCount(){
		return 3;
	}

}
